﻿//using SharpSoft.Documentation.Html.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharpSoft.Documentation.Html.CSS
{
    /// <summary>
    /// 框架规则，用于从WebBrowser中查找框架元素
    /// </summary>
    public struct FrameRule : IRule
    {
        public FrameRule(string name)
        {
            _Name = name;
            _RelationType = CssSelectorRuleRelationType.And;
        }

        private string _Name;
        /// <summary>
        /// 为null或空字符表示不匹配frame名称
        /// </summary>
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private CssSelectorRuleRelationType _RelationType;
        /// <summary>
        /// 获取或设置当前规则与下一个规则的关系，对于选择器中的最后一个规则，此设置无效
        /// </summary>
        public CssSelectorRuleRelationType RelationType
        {
            get { return _RelationType; }
            set { _RelationType = value; }
        }

        public override string ToString()
        {
            return "Frame规则：" + Name;
        }

        //public INodeFilter ToNodeFilter()
        //{
        //    var frame = new TagNameFilter("frame");
        //    var iframe = new TagNameFilter("iframe");
        //    OrFilter or = new OrFilter(frame, iframe);//Tag为frame或iframe
        //    if (string.IsNullOrEmpty(Name))
        //    {
        //        return or;
        //    }
        //    var name = new AttributeRegexFilter("name", "^" + Name + "$");//匹配frame名称
        //    return new AndFilter(or, name);
        //}
    }
}
